#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include "diagramitem.h"
#include "newProjectConfigDialog.h"
#include "treefiles.h"

class QAction;
class QToolBox;
class QSpinBox;
class QComboBox;
class QFontComboBox;
class QButtonGroup;
class DiagramScene;
class QListWidget;
class QLineEdit;
class QGraphicsTextItem;
class QFont;
class QToolButton;
class QAbstractButton;
class QGraphicsView;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow();

private slots:
    /* slots de lancement des options du menu File */
    void newProjectWindow();

    /* slots de lancement de la création du nouveau projet */
    void launchNewProject(QString projectPath);

    void openProjectWindow();
    void saveProjectWindow();

    /* slots de zoom */
    void increaseZoom();
    void decreaseZoom();

    /* gestion du fenétrage */
    void dockWindow();
    void undockWindow();

    void backgroundButtonGroupClicked(QAbstractButton *button);
    void buttonGroupClicked(int id);
    // void deleteItem();
    void pointerGroupClicked(int id);
    void itemInserted(DiagramItem *item);
    void textInserted(QGraphicsTextItem *item);
    // void currentFontChanged(const QFont &font);
    // void fontSizeChanged(const QString &size);

    /* -- Zoom -- */
    void sceneScaleIncreased();
    void sceneScaleDecreased();
    void sceneScaleChanged(const QString &scale);

    void textColorChanged();
    void itemColorChanged();
    void lineColorChanged();
    void textButtonTriggered();
    void fillButtonTriggered();
    void lineButtonTriggered();
    void handleFontChange();
    void itemSelected(QGraphicsItem *item);
    void about();
    void help();

 private:
    void createToolBox();
    void createActions();
    void createMenus();
    void createToolbars();
    QWidget *createBackgroundCellWidget(const QString &text,
                                        const QString &image);
    QWidget *createCellWidget(const QString &text,
                              DiagramItem::DiagramType type);
    QMenu *createColorMenu(const char *slot, QColor defaultColor);
    QIcon createColorToolButtonIcon(const QString &image, QColor color);
    QIcon createColorIcon(QColor color);

    /* -- Fenêtres de dialogue -- */
    newProjectConfigDialog * dialogNewProject;

    /* -- Composant graph -- */
    DiagramScene * scene;

    /* -- Vue du graphe -- */
    QGraphicsView * graphView;

    /* -- docks widgets -- */
    QDockWidget * dock;
    QDockWidget * dock2;
    TreeFiles * tree;
    QListWidget * metricsList;

    /* -- options des menus -- */
    QAction * newProjectAction;      // File > New Project
    QAction * openProjectAction;     // File > Open Project
    QAction * saveProjectAction;     // File > Save Project
    QAction * exitAction;            // File > Exit

    QAction * dockWindowAction;       // View > Dock window
    QAction * undockWindowAction;       // View > Undock window

    QAction * increaseZoomAction;    // Graph > Zoom +
    QAction * decreaseZoomAction;    // Graph > Zoom -
    QAction * graphOptionsAction;    // Graph > Graph Options

    QAction * makeAnalysisAction;
    QAction * viewGraphAction;
    QAction * analysisPropertiesAction;

    QAction * aboutAction;

    /* -- menus -- */
    QMenu * fileMenu;
    QMenu * viewMenu;
    QMenu * graphMenu;
    QMenu * analysisMenu;
    QMenu * helpMenu;
    QMenu * toolbarMenu;

    QToolBar * graphViewToolBar;
    QToolBar * graphEditToolBar;
    QComboBox * graphScaleCombo;
    QComboBox *itemColorCombo;
    QComboBox *textColorCombo;
    QComboBox *fontSizeCombo;
    QFontComboBox *fontCombo;
    QToolBox *toolBox;
    QButtonGroup *buttonGroup;
    QButtonGroup *pointerTypeGroup;
    QButtonGroup *backgroundButtonGroup;
    QToolButton *fontColorToolButton;
    QToolButton *fillColorToolButton;
    QToolButton *lineColorToolButton;
    QAction *boldAction;
    QAction *underlineAction;
    QAction *italicAction;
    QAction *textAction;
    QAction *fillAction;
    QAction *lineAction;
};

#endif
